package com.sbr.seb.entity.planning;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sbr.seb.entity.livraison.Application;

@Entity
public class DemandeDeLivraison implements Serializable {

	protected static final Logger logger = LoggerFactory.getLogger(DemandeDeLivraison.class);
	
	@Id
	@GeneratedValue
	private int id;
	@Enumerated(EnumType.STRING)
	private DemandeState demandeState;
	private Date demandDate;
	
	@OneToOne
	private Application application;
	private int deliveryWeek;
	
	@Enumerated(EnumType.STRING)
	private Environnement environnement;
	
	public DemandeDeLivraison() {
		this.application = new Application();
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public DemandeState getDemandeState() {
		return demandeState;
	}
	public void setDemandeState(DemandeState demandeState) {
		this.demandeState = demandeState;
	}
	public Date getDemandDate() {
		return demandDate;
	}
	public void setDemandDate(Date demandDate) {
		this.demandDate = demandDate;
	}
	public Application getApplication() {
		return application;
	}
	public void setApplication(Application application) {
		this.application = application;
	}
	public int getDeliveryWeek() {
		return deliveryWeek;
	}
	public void setDeliveryWeek(int deliveryWeek) {
		this.deliveryWeek = deliveryWeek;
	}
	public Environnement getEnvironnement() {
		return environnement;
	}
	public void setEnvironnement(Environnement environnement) {
		this.environnement = environnement;
	}

	@Override
	public String toString() {
		return "DemandeDeLivraison [application=" + application
				+ ", deliveryWeek=" + deliveryWeek + ", demandDate="
				+ demandDate + ", demandeState=" + demandeState
				+ ", environnement=" + environnement + ", id=" + id + "]";
	}
	
	public boolean isDemandInMonth(Month month) {
		Calendar calendar = Calendar.getInstance();
		calendar.set(deliveryWeek, Calendar.WEEK_OF_YEAR);
		logger.debug("{} {}",month.getNumber(),calendar.get(Calendar.MONTH));
		if (month.getNumber() == calendar.get(Calendar.MONTH)) {
			return true;
		}
		return false;
	}
	
	public int getDayOfDelivery(){
		return 02;
	}
	
	public boolean isDayOfDelivery(int dayNumber){
		return true;
	}
	
	
}
